import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;


public class KDF1 {
	WebDriver driver;
	@Test
	public void myTest() throws Exception{
		driver = new InternetExplorerDriver();
		// TC002 - Incorrect login
		//	Go To youtube.com
		//	Click the "Sign In" button
		//	Enter Email
		//	Enter Pswd
		//	Click Sign in button
		fLogin();
		//	Confirm error message
		//	The username or password you entered is incorrect.
		// 	Close browser and walk out
		String fromWhere = "//span[@id='errormsg_0_Passwd']";
		String withWhat = "The username or password you entered is incorrect.";
		System.out.println(" TC002 is a " + getAndCompare(fromWhere, withWhat));

		//driver.quit();
		
		
		// TC006 - Incorrect login

		fLogin();
		//	Confirm error message
		//	The username or password you entered is incorrect.
		// 	Close browser and walk out
		String fromWhere1 = "//html/body/div/div[2]/div[2]/h2";
		//descendant::h2[3]
		String withWhat1 = "Sign in to YouTube!";
		System.out.println(" TC006 is a " + getAndCompare(fromWhere, withWhat));

		driver.quit();
	}
	
	public void fLogin() throws Exception{
		driver.navigate().to("youtube.com");
		Thread.sleep(1000);
		//driver.findElement(By.xpath("//*[@id='masthead-user-button']")).click();
		driver.findElement(By.xpath("//*[@id='masthead-user-button']")).sendKeys("\n");
		Thread.sleep(2000);
		driver.findElement(By.xpath("//input[@id='Email']")).clear();
		driver.findElement(By.xpath("//input[@id='Email']")).sendKeys("kartdfgdfg@gmail.com");
		driver.findElement(By.xpath("//input[@name='Passwd']")).clear();
		driver.findElement(By.xpath("//input[@name='Passwd']")).sendKeys("sdfsdfsdf");
		driver.findElement(By.xpath("//input[@type='submit']")).click();
		Thread.sleep(2000);
	}
	
	public String getAndCompare(String s1, String s2){

		String vTemp = driver.findElement(By.xpath(s1)).getText();
		
		if (vTemp.equalsIgnoreCase(s2)){
			return "Pass";
		} else {
			return "Fail";
		}
	}

}
